Skip to content

BUG: Reject transform parameter counts that exceed the metric limit - #6991

Open
jdotc1 wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
jdotc1:fix/jdotc1-metric-count-overflow-20261022
Open

jdotc1 wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
jdotc1:fix/jdotc1-metric-count-overflow-20261022

Conversation

@jdotc1

@jdotc1 jdotc1 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Reject transform parameter counts that exceed the metric return type. Addresses the diagnostic-guard alternative in #6949.

Scope and risk

This rejects unsupported large counts; it does not add a 64-bit metric API or fix every allocation path. The test uses a dummy count and must not allocate a multi-billion-voxel field.

Validation

6 isolated method-body boundary cases compile and pass under GCC with AddressSanitizer/UndefinedBehaviorSanitizer.

Native ITK validation is now available for current head 5cecfc06745aa8c5e6153e3215b1b5323a52d2ee. The Linux ARM64 job compiled with zero compiler errors and warnings and passed all 4,722 configured tests. The actual CountMetric/CountTransform GTest fixture compiled, and both ObjectToObjectMetric.PreservesRepresentableParameterCounts and ObjectToObjectMetric.RejectsParameterCountOverflow passed.

The current-head platform matrix has completed: 18 checks passed, with no pending or failing reported checks. The only skipped job is publish-doxygen-tagfile. Completed checks include Windows C++, macOS and Ubuntu Pixi C++, x86_64 Rosetta, ARM Python, Azure Linux and macOS Python, pre-commit, Doxygen, performance and documentation. The native Linux ARM64 test results above are reused; no tests were repeated for this status update.

Ready for maintainer review. The results establish the native tests on the completed configurations; they do not establish every possible platform-dependent integer-width combination. Maintainer review is needed before merging.

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Numerics Issues affecting the Numerics module labels Oct 22, 2026
@jdotc1
jdotc1 marked this pull request as ready for review October 23, 2026 04:28
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds a check in GetNumberOfParameters() that throws before a transform count can overflow the metric’s return type.

  • Metrics reject transform parameter counts they cannot represent.

No actionable issues found. This review checked the code and test setup; it did not run the tests.

Reviews (1) · Last reviewed commit: "COMP: Complete parameter-count metric te..." · Reviewed by Greptile

@hjmjohnson
hjmjohnson force-pushed the fix/jdotc1-metric-count-overflow-20261022 branch from 5cecfc0 to cfd822c Compare October 25, 2026 19:57
ObjectToObjectMetric::GetNumberOfParameters returned the moving
transform's 64-bit IdentifierType count through the metric's unsigned
int NumberOfParametersType, so a dense displacement field with more
than 2^32 - 1 parameters was silently truncated. Callers then sized the
derivative from the truncated count and wrote past its end.

Throw instead when the count does not fit. This makes the overflow a
clear error; widening the metric API remains open.

Addresses InsightSoftwareConsortium#6949.
@hjmjohnson
hjmjohnson force-pushed the fix/jdotc1-metric-count-overflow-20261022 branch from cfd822c to cc15831 Compare October 25, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Numerics Issues affecting the Numerics module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant